package reflect;

public class Test {
    private static void test1() {
        char[] cs = new char[]{'a', 'b', 'c'};
        String s1 = new String(cs);
        String s = s1.intern();
        String s2 = "abc";
        System.out.println(s1 == s2);
        System.out.println(s);
    }

    private static void test3() {
        try {
            Class<?> c = Class.forName("reflect.Student");
            Student stu = (Student) c.newInstance();
            System.out.println(stu);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private static void test2() {
        try {
            Class<Student> c1 = (Class<Student>)Class.forName("reflect.Student");
            Class c2 = Student.class;

            Student s = new Student();
            Class c3 = s.getClass();

            System.out.println(c1 == c2);
            System.out.println(c1 == c3);
            System.out.println(c2 == c3);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main(String[] args) {
//        test1();
//        test2();
        test3();
    }
}
